﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDxfDocument
{
    class 英洛航空
    {
        
        public static void StraightFluteTapINNOV(Dictionary<string, Object> data)    
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            
            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var isframe = 0.0;
            try
            {
                isframe = Convert.ToDouble(data["isframe"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[isframe] not found");
            }
            var soal = 72.0;//总长度
            try
            {
                soal = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[soal] not found");
            }
            double scale = Convert.ToDouble(data["scale"]);
            if (scale == 0 && isframe == 1) 
            {
                var x = 72 / soal * 8;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 2) 
            {
                var x = 72 / soal * 5;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 3) 
            {
                var x = 72 / soal * 3;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 4) 
            {
                var x = 72 / soal * 2;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 5) 
            {
                var x = 72 / soal * 0.8;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 6) 
            {
                var x = 72 / soal * 8;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 7) 
            {
                var x = 72 / soal * 5;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 8) 
            {
                var x = 72 / soal * 3;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 9) 
            {
                var x = 72 / soal * 2;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 10) 
            {
                var x = 72 / soal * 1;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 11) 
            {
                var x = 72 / soal * 1.75;
                scale = Math.Round(x, 1);
            }
            if (scale == 0 && isframe == 0) 
            {
                scale = 1;
            }
            var d = 8.0 * scale; //螺纹直径
            try
            {
                d = Convert.ToDouble(data["td"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var tp = 1.25 * scale;//螺距
            try
            {
                tp = Convert.ToDouble(data["tp"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[tp] not found");
            }
            var L = 72.0 * scale;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var l1 = 18.8 * scale;//螺纹长度
            try
            {
                l1 = Convert.ToDouble(data["thl"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[l1] not found");
            }
            var l2 = 37.0 * scale;//可用长度
            try
            {
                l2 = Convert.ToDouble(data["lu"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[l2] not found");
            }
            var l3 = L - l2;//柄部长度
            var d1 = 6.3 * scale;//柄部直径
            try
            {
                d1 = Convert.ToDouble(data["dconms"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var k = 5.0 * scale;//驱动器尺寸代码
            try
            {
                k = Convert.ToDouble(data["drvsc"]) * scale;
            }
            catch (Exception e)
            {
                Console.WriteLine("[k] not found");
            }
            var sjqm = Convert.ToString(data["sjqm"]);
            var shqm = Convert.ToString(data["shqm"]);
            var xdqm = Convert.ToString(data["jdqm"]);
            var sjrq = Convert.ToString(data["sjrq"]);
            var shrq = Convert.ToString(data["shrq"]);
            var xdrq = Convert.ToString(data["jdrq"]);
            var cdes = Convert.ToString(data["cdes"]);
            var des = Convert.ToString(data["des"]);
            var lh = Convert.ToString(data["lh"]);
            var bmc = Convert.ToString(data["bmc"]);
            var coatn = Convert.ToString(data["coatn"]);
            var cnsc = Convert.ToString(data["cnsc"]);
            var bbh = Convert.ToString(data["bbh"]);
            var jstj = Convert.ToString(data["jstj"]);
            
            /*
            var d = 3.0;
            var tp = 0.5;
            var L = 48.0;
            var l1 = 7.5;
            var l2 = 19.0;
            var l3 = L - l2;
            var d1 = 3.15;
            var k = 2.5;
           
            var sjqm = "蔡徐坤";
            var shqm = "蔡徐坤";
            var xdqm = "蔡徐坤";
            var sjrq = "2024.04.18";
            var shrq = "2024.04.18";
            var xdrq = "2024.04.18";
            var cdes = "整硬内冷涂层挤压丝锥";
            var des = "M6-6HX 2P HM DLC IC";
            var lh = "N02258";
            var bmc = "HM";
            var coatn = "DLC";
            var cnsc = "IC";
            var bbh = "A1";
            var jstj = "";

            var scale = 1;
             */
            //作图

            //柄部

            var v1 = new Vector2(0, 0);
            var v0 = fun.Polar(v1, pi, L);
            var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
            var v3 = fun.Polar(v2, pi, 0.8 / 3.31 * d1 / 2);
            var v8 = fun.Polar(v2, -90 * pi / 180, 1.48 / 3.31 * d1 / 2);
            var v9 = fun.Polar(v8, pi, 8.38 / 43.52 * l3);
            var v6 = fun.Polar(v2, pi, fun.CalDistance(v8, v9));
            var v5 = fun.Polar(v6, 0, fun.CalDistance(v3, v2));
            var v4 = fun.mirrorpoint(v3, v8, v9);
            var v7 = fun.mirrorpoint(v5, v8, v9);
            var v10 = fun.Polar(v2, pi, l3);
            var v3p = fun.mirrorpoint(v3, v0, v1);
            var v4p = fun.mirrorpoint(v4, v0, v1);
            var v5p = fun.mirrorpoint(v5, v0, v1);
            var v6p = fun.mirrorpoint(v6, v0, v1);
            var v7p = fun.mirrorpoint(v7, v0, v1);
            var v8p = fun.mirrorpoint(v8, v0, v1);
            var v9p = fun.mirrorpoint(v9, v0, v1);
            var v10p = fun.mirrorpoint(v10, v0, v1);



            var arc1 = fun.DrawArc3(v4, v8, v3);
            var arc2 = fun.DrawArc3(v5, v9, v7);
            var arc3 = fun.DrawArc3(v3p, v8p, v4p);
            var arc4 = fun.DrawArc3(v7p, v9p, v5p);
            var line1 = new Line(v8, v8p);
            var polyline1 = Pus.AddPointsToLwPolyLine(v7, v4, v4p, v7p, v7);
            var polyline2 = Pus.AddPointsToLwPolyLine(v3, v5, v6);
            var polyline3 = Pus.AddPointsToLwPolyLine(v3p, v5p, v6p);
            var polyline4 = Pus.AddPointsToLwPolyLine(v6, v6p, v10p, v10, v6);

            //dxf.AddEntity(new EntityObject[] { arc1, arc2, arc3, arc4, line1, polyline1, polyline2, polyline3, polyline4 });


            fun.drawBArc(dxf, arc1, 0.2, contour);
            fun.drawBArc(dxf, arc2, 0.2, contour);
            fun.drawBArc(dxf, arc3, 0.2, contour);
            fun.drawBArc(dxf, arc4, 0.2, contour);
            fun.drawBline(dxf, line1, 0.2, contour); 
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            fun.PolyFill(dxf, polyline2, 0.2, contour);
            fun.PolyFill(dxf, polyline3, 0.2, contour);
            fun.PolyFill(dxf, polyline4, 0.2, contour);

            //颈部
            var v11 = fun.Polar(v10, -90 * pi / 180, 0.27 / 3.31 * d1 / 2);
            var v12 = fun.Polar(v11, pi, l2 - l1);
            var v13= fun.Polar(v12, -90 * pi / 180, 0.41 / 3.31 * d1 / 2);
            var v14 = fun.Polar(v13, 0, 7.6 / 15.96 * (l2 - l1));
            var v15 = new Vector2(v14.X + 3.31 / 15.96 * (l2 - l1), v14.Y - 0.51 / 3.31 * d1 / 2);
            var v16 = new Vector2(v15.X + 0.16 / 15.96 * (l2 - l1), v15.Y - 1.2 / 3.31 * d1 / 2);
            var v17 = new Vector2(v14.X + 0.64 / 15.96 * (l2 - l1), v1.Y);
            var v18 = new Vector2(v12.X, v1.Y);
            var v19 = fun.Polar(v18, -90 * pi / 180, 1.85 / 3.31 * d1 / 2);
            var v20 = fun.Polar(v19, 0, 8.18 / 15.96 * (l2 - l1));
            var v21 = new Vector2(v20.X + 3.08 / 15.96 * (l2 - l1), v20.Y - 0.53 / 3.31 * d1 / 2);
            var v12p = fun.mirrorpoint(v12, v0, v1);
            var v11p = fun.mirrorpoint(v11, v0, v1);
            var v22 = fun.Polar(v12p, 0, 11.3 / 15.96 * (l2 - l1));

            var line2 = new Line(v12, v11);
            var line3 = new Line(v12p, v11p);
            var polyline5 = Pus.AddPointsToLwPolyLine(v13, v14, v15, v16, v17, v18);
            polyline5.Vertexes[1].Bulge = -Math.Tan(11 * pi / 180 / 4);
            polyline5.Vertexes[2].Bulge = -Math.Tan(135 * pi / 180 / 4);
            polyline5.Vertexes[3].Bulge = -Math.Tan(30 * pi / 180 / 4);
            var polyline6 = Pus.AddPointsToLwPolyLine( v20, v21, v22);
            polyline6.Vertexes[0].Bulge = -Math.Tan(15 * pi / 180 / 4);
            polyline6.Vertexes[1].Bulge = -Math.Tan(140 * pi / 180 / 4);


            //dxf.AddEntity(new EntityObject[] { line2, polyline5, polyline6 });

            fun.drawBline(dxf, line2, 0.2, contour);
            fun.PolyFill(dxf, polyline5, 0.2, contour);
            fun.PolyFill(dxf, polyline6, 0.2, contour);

            //切削部分
            var v23 = new Vector2(v12.X, v1.Y + d / 2);
            var v24 = fun.Polar(v23, pi, l1);
            var v25 = fun.mirrorpoint(v24, v1, v0);
            var v26 = fun.mirrorpoint(v23, v1, v0);
            var v27 = new Vector2(v12.X - 0.75 / 15.64 * l1, v1.Y + 3.76 / 4 * d / 2);
            var v27p = new Vector2(v12.X - 1.14 / 15.64 * l1, v1.Y + 3.28 / 4 * d / 2);
            var v28 = fun.Polar(v23, pi, 1.58 / 15.64 * l1);
            var v29 = fun.Polar(v27p, pi, 1.0352 / 15.64 * l1);
            var v30 = fun.Polar(v28, pi, 1.0352 / 15.64 * l1);
            var v31 = fun.Polar(v29, pi, 1.0352 / 15.64 * l1);
            var v32 = fun.Polar(v30, pi, 1.0352 / 15.64 * l1);
            var v33 = fun.Polar(v31, pi, 1.0352 / 15.64 * l1);
            var v34 = fun.Polar(v32, pi, 1.0352 / 15.64 * l1);
            var v35 = fun.Polar(v33, pi, 1.0352 / 15.64 * l1);
            var v36 = fun.Polar(v34, pi, 1.0352 / 15.64 * l1);
            var v37 = fun.Polar(v35, pi, 1.0352 / 15.64 * l1);
            var v38 = fun.Polar(v36, pi, 1.0352 / 15.64 * l1);
            var v39 = fun.Polar(v37, pi, 1.0352 / 15.64 * l1);
            var v40 = fun.Polar(v38, pi, 1.0352 / 15.64 * l1);
            var v41 = fun.Polar(v39, pi, 1.0352 / 15.64 * l1);
            var v42 = fun.Polar(v40, pi, 1.0352 / 15.64 * l1);
            var v43 = fun.Polar(v41, pi, 1.0352 / 15.64 * l1);
            var v44 = fun.Polar(v42, pi, 1.0352 / 15.64 * l1);
            var v45 = fun.Polar(v43, pi, 1.0352 / 15.64 * l1);
            var v46 = fun.Polar(v44, pi, 1.0352 / 15.64 * l1);
            var v47 = fun.Polar(v45, pi, 1.0352 / 15.64 * l1);
            var v48 = fun.Polar(v46, pi, 1.0352 / 15.64 * l1);
            var v49 = fun.Polar(v47, pi, 1.0352 / 15.64 * l1);
            var v50 = fun.Polar(v48, pi, 1.0352 / 15.64 * l1);
            var v51 = fun.Polar(v49, pi, 1.0352 / 15.64 * l1);
            var v52 = fun.Polar(v50, pi, 1.0352 / 15.64 * l1);
            var v53 = fun.Polar(v51, pi, 1.0352 / 15.64 * l1);
            var v54 = fun.Polar(v52, pi, 1.0352 / 15.64 * l1);
            var v55 = fun.Polar(v53, pi, 1.0352 / 15.64 * l1);
            var v56 = fun.Polar(v24, -90 * pi / 180, 0.81 / 8.9 * d);
            var v57 = fun.Inters(v13, fun.Polar(v13, fun.CalAngle(v12, v27) + 8 * pi / 180, 1), v27, fun.Polar(v27, 275 * pi / 180, 1));
            var v58 = fun.Polar(v27p, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v59 = fun.Polar(v28, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v60 = fun.Polar(v29, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v61 = fun.Polar(v30, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v62 = fun.Polar(v31, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v63 = fun.Polar(v32, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v64 = fun.Polar(v33, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v65 = fun.Polar(v34, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v66 = fun.Polar(v35, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v67 = fun.Polar(v36, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v68 = fun.Polar(v37, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v69 = fun.Polar(v38, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v70 = fun.Polar(v39, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v71 = fun.Polar(v40, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v72 = fun.Polar(v41, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v73 = fun.Polar(v42, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v74 = fun.Polar(v43, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v75 = fun.Polar(v44, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v76 = fun.Polar(v45, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v77 = fun.Polar(v46, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v78 = fun.Polar(v47, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v79 = fun.Polar(v48, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v80 = fun.Polar(v49, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v81 = fun.Polar(v50, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v82 = fun.Polar(v51, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v83 = fun.Polar(v52, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v84 = fun.Polar(v53, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v85 = fun.Polar(v54, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v86 = fun.Polar(v55, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v87 = fun.Polar(v24, -90 * pi / 180, 1.65 / 8.9 * d);
            var c1 = fun.Inters(v50, v55, v51, v52);
            var c2 = fun.Inters(v50, v55, v53, v52);
            var c3 = fun.Inters(v50, v55, v53, v54);
            var c4 = fun.Inters(v81, v86, v82, v83);
            var c5 = fun.Inters(v81, v86, v83, v84);
            var c6 = fun.Inters(v81, v86, v84, v85);
            var v88 = fun.Inters(v27p, v58, v25, v26);
            var v89 = fun.Polar(v88, fun.CalAngle(v58, v59), fun.CalDistance(v58, v59));
            var v90 = fun.Inters(v29, v60, v25, v26);
            var v91 = fun.Polar(v90, fun.CalAngle(v58, v59), fun.CalDistance(v58, v59));
            var v88p = fun.Inters(v88, fun.Polar(v88, fun.CalAngle(v90, v89), 1), v12p, fun.Polar(v12p, pi, 1));
            var v92 = fun.Polar(v90, pi, fun.CalDistance(v88, v90));
            var v93 = fun.Polar(v91, pi, fun.CalDistance(v89, v91));
            var v94 = fun.Polar(v92, pi, fun.CalDistance(v89, v91));
            var v95 = fun.Polar(v93, pi, fun.CalDistance(v89, v91));
            var v96 = fun.Polar(v94, pi, fun.CalDistance(v89, v91));
            var v97 = fun.Polar(v95, pi, fun.CalDistance(v89, v91));
            var v98 = fun.Polar(v96, pi, fun.CalDistance(v89, v91));
            var v99 = fun.Polar(v97, pi, fun.CalDistance(v89, v91));
            var v100 = fun.Polar(v98, pi, fun.CalDistance(v89, v91));
            var v101 = fun.Polar(v99, pi, fun.CalDistance(v89, v91));
            var v102 = fun.Polar(v100, pi, fun.CalDistance(v89, v91));
            var v103 = fun.Polar(v101, pi, fun.CalDistance(v89, v91));
            var v104 = fun.Polar(v102, pi, fun.CalDistance(v89, v91));
            var v105 = fun.Polar(v103, pi, fun.CalDistance(v89, v91));
            var v106 = fun.Polar(v104, pi, fun.CalDistance(v89, v91));
            var v107 = fun.Polar(v105, pi, fun.CalDistance(v89, v91));
            var v108 = fun.Polar(v106, pi, fun.CalDistance(v89, v91));
            var v109 = fun.Polar(v107, pi, fun.CalDistance(v89, v91));
            var v110 = fun.Polar(v108, pi, fun.CalDistance(v89, v91));
            var v111 = fun.Polar(v109, pi, fun.CalDistance(v89, v91));
            var v112 = fun.Polar(v110, pi, fun.CalDistance(v89, v91));
            var v113 = fun.Polar(v111, pi, fun.CalDistance(v89, v91));
            var v114 = fun.Polar(v112, pi, fun.CalDistance(v89, v91));
            var v115 = fun.Polar(v113, pi, fun.CalDistance(v89, v91));
            var v116 = fun.Polar(v114, pi, fun.CalDistance(v89, v91));
            var v117 = fun.Polar(v25, 90 * pi / 180, 0.84 / 8.9 * d);
            var c7 = fun.Inters(v113, v114, v112, v117);
            var c8 = fun.Inters(v115, v114, v112, v117);
            var c9 = fun.Inters(v115, v116, v112, v117);
            var v118 = fun.Polar(v1, pi, L);
            var v119 = fun.Polar(v118, -90 * pi / 180, 2.04 / 8 * d);
            var v121p = fun.Polar(v118, -90 * pi / 180, 2.78 / 8 * d);
            var v121 = fun.Inters(v58, v88, v121p, fun.Polar(v121p, 0, 1));
            var v120p = fun.Polar(v121, fun.CalAngle(v90, v89), fun.CalDistance(v90, v89));
            var v120 = fun.Inters(v121, v120p, v19, fun.Polar(v19, pi, 1));
            var v122 = fun.Polar(v121, fun.CalAngle(v88, v89), fun.CalDistance(v88, v89));
            var v123 = fun.Polar(v121, pi, fun.CalDistance(v88, v90));
            var v124 = fun.Polar(v122, pi, fun.CalDistance(v88, v90));
            var v125 = fun.Polar(v123, pi, fun.CalDistance(v88, v90));
            var v126 = fun.Polar(v124, pi, fun.CalDistance(v88, v90));
            var v127 = fun.Polar(v125, pi, fun.CalDistance(v88, v90));
            var v128 = fun.Polar(v126, pi, fun.CalDistance(v88, v90));
            var v129 = fun.Polar(v127, pi, fun.CalDistance(v88, v90));
            var v130 = fun.Polar(v128, pi, fun.CalDistance(v88, v90));
            var v131 = fun.Polar(v129, pi, fun.CalDistance(v88, v90));
            var v132 = fun.Polar(v130, pi, fun.CalDistance(v88, v90));
            var v133 = fun.Polar(v131, pi, fun.CalDistance(v88, v90));
            var v134 = fun.Polar(v132, pi, fun.CalDistance(v88, v90));
            var v135 = fun.Polar(v133, pi, fun.CalDistance(v88, v90));
            var v136 = fun.Polar(v134, pi, fun.CalDistance(v88, v90));
            var v137 = fun.Polar(v135, pi, fun.CalDistance(v88, v90));
            var v138 = fun.Polar(v136, pi, fun.CalDistance(v88, v90));
            var v139 = fun.Polar(v137, pi, fun.CalDistance(v88, v90));
            var v140 = fun.Polar(v138, pi, fun.CalDistance(v88, v90));
            var v141 = fun.Polar(v139, pi, fun.CalDistance(v88, v90));
            var v142 = fun.Polar(v140, pi, fun.CalDistance(v88, v90));
            var v143 = fun.Polar(v141, pi, fun.CalDistance(v88, v90));
            var v144 = fun.Polar(v142, pi, fun.CalDistance(v88, v90));
            var v145 = fun.Polar(v143, pi, fun.CalDistance(v88, v90));
            var v1450 = fun.Polar(v144, pi, fun.CalDistance(v88, v90));
            var v1451 = fun.Polar(v145, pi, fun.CalDistance(v88, v90));
            var v1452 = fun.Polar(v1450, pi, fun.CalDistance(v88, v90));
            var v1453 = fun.Polar(v1451, pi, fun.CalDistance(v88, v90));
            var c10 = fun.Inters(v145, v119, v1450, v1451);
            var c11 = fun.Inters(v145, v119, v1452, v1451);
            var c12 = fun.Inters(v145, v119, v1453, v1452);
            var v147 = fun.Inters(v121, v88, v1, v118);
            var v146 = fun.Inters(v120, fun.Polar(v120, fun.CalAngle(v121, v147), 1), v1, v118);
            var v148 = fun.Inters(v121, fun.Polar(v121, fun.CalAngle(v121, v147), 1), v1, v118);
            var v149 = fun.Inters(v122, fun.Polar(v122, fun.CalAngle(v121, v147), 1), v1, v118);
            var v150 = fun.Inters(v123, fun.Polar(v123, fun.CalAngle(v121, v147), 1), v1, v118);
            var v151 = fun.Inters(v124, fun.Polar(v124, fun.CalAngle(v121, v147), 1), v1, v118);
            var v152 = fun.Inters(v125, fun.Polar(v125, fun.CalAngle(v121, v147), 1), v1, v118);
            var v153 = fun.Inters(v126, fun.Polar(v126, fun.CalAngle(v121, v147), 1), v1, v118);
            var v154 = fun.Inters(v127, fun.Polar(v127, fun.CalAngle(v121, v147), 1), v1, v118);
            var v155 = fun.Inters(v128, fun.Polar(v128, fun.CalAngle(v121, v147), 1), v1, v118);
            var v156 = fun.Inters(v129, fun.Polar(v129, fun.CalAngle(v121, v147), 1), v1, v118);
            var v157 = fun.Inters(v130, fun.Polar(v130, fun.CalAngle(v121, v147), 1), v1, v118);
            var v158 = fun.Inters(v131, fun.Polar(v131, fun.CalAngle(v121, v147), 1), v1, v118);
            var v159 = fun.Inters(v132, fun.Polar(v132, fun.CalAngle(v121, v147), 1), v1, v118);
            var v160 = fun.Inters(v133, fun.Polar(v133, fun.CalAngle(v121, v147), 1), v1, v118);
            var v161 = fun.Inters(v134, fun.Polar(v134, fun.CalAngle(v121, v147), 1), v1, v118);
            var v162 = fun.Inters(v135, fun.Polar(v135, fun.CalAngle(v121, v147), 1), v1, v118);
            var v163 = fun.Inters(v136, fun.Polar(v136, fun.CalAngle(v121, v147), 1), v1, v118);
            var v164 = fun.Inters(v137, fun.Polar(v137, fun.CalAngle(v121, v147), 1), v1, v118);
            var v165 = fun.Inters(v138, fun.Polar(v138, fun.CalAngle(v121, v147), 1), v1, v118);
            var v166 = fun.Inters(v139, fun.Polar(v139, fun.CalAngle(v121, v147), 1), v1, v118);
            var v167 = fun.Inters(v140, fun.Polar(v140, fun.CalAngle(v121, v147), 1), v1, v118);
            var v168 = fun.Inters(v141, fun.Polar(v141, fun.CalAngle(v121, v147), 1), v1, v118);
            var v169 = fun.Inters(v142, fun.Polar(v142, fun.CalAngle(v121, v147), 1), v1, v118);
            var v170 = fun.Inters(v143, fun.Polar(v143, fun.CalAngle(v121, v147), 1), v1, v118);
            var v171 = fun.Inters(v144, fun.Polar(v144, fun.CalAngle(v121, v147), 1), v1, v118);
            var v172 = fun.Inters(v145, fun.Polar(v145, fun.CalAngle(v121, v147), 1), v1, v118);
            var v173 = fun.Inters(v1450, fun.Polar(v1450, fun.CalAngle(v121, v147), 1), v1, v118);
            var v174 = fun.Inters(v1452, fun.Polar(v1452, fun.CalAngle(v121, v147), 1), v1, v118);
            var v175 = fun.Inters(c10, fun.Polar(c10, fun.CalAngle(v121, v147), 1), v1, v118);
            var v176 = fun.Inters(c11, fun.Polar(c11, fun.CalAngle(v121, v147), 1), v1, v118);
            var v177 = fun.Inters(c12, fun.Polar(c12, fun.CalAngle(v121, v147), 1), v1, v118);





            var polyline7 = Pus.AddPointsToLwPolyLine(v12, v27, v27p, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, c1, c2, v53, c3, v55, v56);
            var polyline8 = Pus.AddPointsToLwPolyLine(v13, v57, v58, v59, v60, v61, v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76, v77, v78, v79, v80, v81, v82, c4, c5, v84, c6, v86, v87);
            var polyline9 = Pus.AddPointsToLwPolyLine(v11p, v88p, v88, v89, v90, v91, v92, v93, v94, v95, v96, v97, v98, v99, v100, v101, v102, v103, v104, v105, v106, v107, v108, v109, v110, v111, v112, v113, c7, c8, v115, c9, v117, v56);
            var polyline10 = Pus.AddPointsToLwPolyLine(v20, v120, v121, v122, v123, v124, v125, v126, v127, v128, v129, v130, v131, v132, v133, v134, v135, v136, v137, v138, v139, v140, v141, v142, v143, v144, v145, v1450, c10, c11, v1452, c12, v119);

            var line4 = new Line(v27, v57);
            var line5 = new Line(v28, v59);
            var line6 = new Line(v29, v60);
            var line7 = new Line(v30, v61);
            var line8 = new Line(v31, v62);
            var line9 = new Line(v32, v63);
            var line10 = new Line(v33, v64);
            var line11 = new Line(v34, v65);
            var line12 = new Line(v35, v66);
            var line13 = new Line(v36, v67);
            var line14 = new Line(v37, v68);
            var line15 = new Line(v38, v69);
            var line16 = new Line(v39, v70);
            var line17 = new Line(v40, v71);
            var line18 = new Line(v41, v72);
            var line19 = new Line(v42, v73);
            var line20 = new Line(v43, v74);
            var line21 = new Line(v44, v75);
            var line22 = new Line(v45, v76);
            var line23 = new Line(v46, v77);
            var line24 = new Line(v47, v78);
            var line25 = new Line(v48, v79);
            var line26 = new Line(v49, v80);
            var line27 = new Line(v50, v81);
            var line28 = new Line(v51, v82);
            var line29 = new Line(v27p, v58);
            var line30 = new Line(c1, c4);
            var line31 = new Line(c2, c5);
            var line32 = new Line(c3, c6);
            var line33 = new Line(v53, v84);
            var line34 = new Line(v55, v86);

            var line35 = new Line(v120, v146);
            var line36 = new Line(v121, v148);
            var line36_ = new Line(v122, v149);
            var line37 = new Line(v123, v150);
            var line38 = new Line(v124, v151);
            var line39 = new Line(v125, v152);
            var line40 = new Line(v126, v153);
            var line41 = new Line(v127, v154);
            var line42 = new Line(v128, v155);
            var line43 = new Line(v129, v156);
            var line44 = new Line(v130, v157);
            var line45 = new Line(v131, v158);
            var line46 = new Line(v132, v159);
            var line47 = new Line(v133, v160);
            var line48 = new Line(v134, v161);
            var line49 = new Line(v135, v162);
            var line50 = new Line(v136, v163);
            var line51 = new Line(v137, v164);
            var line52 = new Line(v138, v165);
            var line53 = new Line(v139, v166);
            var line54 = new Line(v140, v167);
            var line55 = new Line(v141, v168);
            var line56 = new Line(v142, v169);
            var line57 = new Line(v143, v170);
            var line58 = new Line(v144, v171);
            var line59 = new Line(v145, v172);
            var line60 = new Line(v1450, v173);
            var line61 = new Line(v1452, v174);
            var line62 = new Line(c10, v175);


            var line63 = new Line(c11, v176);
            var line64 = new Line(c12, v177);
            var line65 = new Line(v18, v118);



            //dxf.AddEntity(new EntityObject[] { polyline7, polyline8, polyline9, polyline10 ,line4, line5, line6, line7, line8, line9, line10, line11, line12, line13, line14, line15, line16, line17, line18, line19, line20, line21, line22, line23, line24, line25, line26, line27, line28, line29, line30, line31, line32, line33, line34 });


            //dxf.AddEntity(new EntityObject[] { line35, line36, line36_, line37, line38, line39, line40, line41, line42, line43, line44, line45, line46, line47, line48, line49, line50, line51, line52, line53, line54, line55, line56, line57, line58, line59, line60, line61, line62, line63, line64, line65 });

            
            fun.drawBline(dxf, line4, 0.2, contour);
            fun.drawBline(dxf, line5, 0.2, contour);
            fun.drawBline(dxf, line6, 0.2, contour);
            fun.drawBline(dxf, line7, 0.2, contour);
            fun.drawBline(dxf, line8, 0.2, contour);
            fun.drawBline(dxf, line9, 0.2, contour);
            fun.drawBline(dxf, line10, 0.2, contour);
            fun.drawBline(dxf, line11, 0.2, contour);
            fun.drawBline(dxf, line12, 0.2, contour);
            fun.drawBline(dxf, line13, 0.2, contour);
            fun.drawBline(dxf, line14, 0.2, contour);
            fun.drawBline(dxf, line15, 0.2, contour);
            fun.drawBline(dxf, line16, 0.2, contour);
            fun.drawBline(dxf, line17, 0.2, contour);
            fun.drawBline(dxf, line18, 0.2, contour);
            fun.drawBline(dxf, line19, 0.2, contour);
            fun.drawBline(dxf, line20, 0.2, contour);
            fun.drawBline(dxf, line21, 0.2, contour);
            fun.drawBline(dxf, line22, 0.2, contour);
            fun.drawBline(dxf, line23, 0.2, contour);
            fun.drawBline(dxf, line24, 0.2, contour);
            fun.drawBline(dxf, line25, 0.2, contour);
            fun.drawBline(dxf, line26, 0.2, contour);
            fun.drawBline(dxf, line27, 0.2, contour);
            fun.drawBline(dxf, line28, 0.2, contour);
            fun.drawBline(dxf, line29, 0.2, contour);
            fun.drawBline(dxf, line30, 0.2, contour);
            fun.drawBline(dxf, line31, 0.2, contour);
            fun.drawBline(dxf, line32, 0.2, contour);
            fun.drawBline(dxf, line33, 0.2, contour);
            fun.drawBline(dxf, line34, 0.2, contour);
            fun.drawBline(dxf, line35, 0.2, contour);
            fun.drawBline(dxf, line36, 0.2, contour);
            fun.drawBline(dxf, line36_, 0.2, contour);
            fun.drawBline(dxf, line37, 0.2, contour);
            fun.drawBline(dxf, line38, 0.2, contour);
            fun.drawBline(dxf, line39, 0.2, contour);
            fun.drawBline(dxf, line40, 0.2, contour);
            fun.drawBline(dxf, line41, 0.2, contour);
            fun.drawBline(dxf, line42, 0.2, contour);
            fun.drawBline(dxf, line43, 0.2, contour);
            fun.drawBline(dxf, line44, 0.2, contour);
            fun.drawBline(dxf, line45, 0.2, contour);
            fun.drawBline(dxf, line46, 0.2, contour);
            fun.drawBline(dxf, line47, 0.2, contour);
            fun.drawBline(dxf, line48, 0.2, contour);
            fun.drawBline(dxf, line49, 0.2, contour);
            fun.drawBline(dxf, line50, 0.2, contour);
            fun.drawBline(dxf, line51, 0.2, contour);
            fun.drawBline(dxf, line52, 0.2, contour);
            fun.drawBline(dxf, line53, 0.2, contour);
            fun.drawBline(dxf, line54, 0.2, contour);
            fun.drawBline(dxf, line55, 0.2, contour);
            fun.drawBline(dxf, line56, 0.2, contour);
            fun.drawBline(dxf, line57, 0.2, contour);
            fun.drawBline(dxf, line58, 0.2, contour);
            fun.drawBline(dxf, line59, 0.2, contour);
            fun.drawBline(dxf, line60, 0.2, contour);
            fun.drawBline(dxf, line61, 0.2, contour);
            fun.drawBline(dxf, line62, 0.2, contour);
            fun.drawBline(dxf, line63, 0.2, contour);
            fun.drawBline(dxf, line64, 0.2, contour);
            fun.drawBline(dxf, line65, 0.2, contour);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            fun.PolyFill(dxf, polyline10, 0.2, contour);

            //基准线

            var a1 = fun.Polar(v1, 0, 10);
            var a2 = fun.Polar(v1, pi, L + 10);
            var a3p = fun.Polar(v1, -90 * pi / 180, 60 * scale);
            var a3 = fun.Polar(a3p, pi, d1);
            var a4 = fun.Polar(a3, pi, 1.5 * k);
            var a5 = fun.Polar(a3, 0, 1.5 * k);
            var a6 = fun.Polar(a3, 90 * pi / 180, 1.5 * k);
            var a7 = fun.Polar(a3, -90 * pi / 180, 1.5 * k);

            var a8 = fun.Polar(a3, 90 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a9 = fun.Polar(a3, 0 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a10 = fun.Polar(a3, -90 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a11 = fun.Polar(a3, 180 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var p1 = fun.Polar(a3, 90 * pi / 180, v3.Y - v1.Y);
            var p2 = fun.Polar(p1, 0, 1);
            var a12 = fun.Inters(p1, p2, a8, a9);
            var a13 = fun.Polar(a9, fun.CalAngle(a9, a8), fun.CalDistance(a8, a12));
            var a14 = fun.Polar(a9, fun.CalAngle(a9, a10), fun.CalDistance(a8, a12));
            var a15 = fun.Polar(a10, fun.CalAngle(a10, a9), fun.CalDistance(a8, a12));
            var a16 = fun.Polar(a10, fun.CalAngle(a10, a11), fun.CalDistance(a8, a12));
            var a17 = fun.Polar(a11, fun.CalAngle(a11, a10), fun.CalDistance(a8, a12));
            var a18 = fun.Polar(a11, fun.CalAngle(a11, a8), fun.CalDistance(a8, a12));
            var a19 = fun.Polar(a8, fun.CalAngle(a8, a11), fun.CalDistance(a8, a12));

            

            var line66 = new Line(a1, a2);
            line66.Layer = centre;
            line66.Lineweight = Lineweight.W25;
            line66.Linetype = Linetype.DashDot;
            var line67 = new Line(a4, a5);
            line67.Layer = centre;
            line67.Lineweight = Lineweight.W25;
            line67.Linetype = Linetype.DashDot;
            var line68 = new Line(a6, a7);
            line68.Layer = centre;
            line68.Lineweight = Lineweight.W25;
            line68.Linetype = Linetype.DashDot;

            var polyline11 = Pus.AddPointsToLwPolyLine(a12, a13, a14, a15, a16, a17, a18, a19, a12);

            //dxf.AddEntity(new EntityObject[] { line66, line67, line68, polyline11 });

            fun.PolyFill(dxf, polyline11, 0.2, contour);
            dxf.AddEntity(new EntityObject[] { line66, line67, line68 });

            var hatchpoly1 = polyline11;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);





            //标注

            var height = 2.5 * scale;//字体高度
            var offset = 10 * scale;//偏移量
            var arrowsize = 1 * scale;//箭头大小
            var exline = 1 * scale;//延伸线长度


            fun.dimrot1(dxf, v3p, v3, -90, offset, 0, height, arrowsize, exline, "DCONMS=" + d1 / scale, "", "");
            fun.dimrot1(dxf, v117, v88p, 180, offset, 0, height, arrowsize, exline, "THL=" + l1 / scale, "", "");
            fun.dimrot1(dxf, v117, v10p, 180, offset * 2, 0, height, arrowsize, exline, "LU=" + l2 / scale, "", "");
            fun.dimrot1(dxf, v117, v8p, 180, offset * 3, 0, height, arrowsize, exline, "OAL=" + L / scale, "", "");
            fun.dimrot1(dxf, a13, a16, -135, offset , 0, height, arrowsize, exline, "DRVSC=" + k / scale, "", "");


            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(v1.X - L / 2 - 500, v1.Y + 180), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 2)
            {
                Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(v1.X - L / 2 - 350, v1.Y + 180), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 3)
            {
                Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(v1.X - L / 2 - 200, v1.Y + 120), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 4)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - L / 2 - 200, v1.Y + 80), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 5)
            {
                Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(v1.X - L / 2 - 140, v1.Y + 60), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 6)
            {
                Dictionary<string, Vector2> position = Frame.frameA0Y(dxf, new Vector2(v1.X - L / 2 - 380, v1.Y + 250));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 7)
            {
                Dictionary<string, Vector2> position = Frame.frameA1Y(dxf, new Vector2(v1.X - L / 2 - 270, v1.Y + 250));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 8)
            {
                Dictionary<string, Vector2> position = Frame.frameA2Y(dxf, new Vector2(v1.X - L / 2 - 180, v1.Y + 200));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 9)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v1.X - L / 2 - 140, v1.Y + 120));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 10)
            {
                Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(v1.X - L / 2 - 100, v1.Y + 120));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            if (isframe == 11)
            {
                Frame.YNframeA4(dxf, new Vector2(v1.X - L / 2 - 110, v1.Y + 50), scale, sjqm, shqm, xdqm, sjrq, shrq, xdrq, cdes, des, lh, bmc, coatn, cnsc, bbh, jstj);
            }



            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }public static void 螺尖丝锥(Dictionary<string, Object> data)    
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            
            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*
            var d = 8.0; //螺纹直径
            try
            {
                d = Convert.ToDouble(data["td"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var tp = 1.25;//螺距
            try
            {
                tp = Convert.ToDouble(data["tp"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[tp] not found");
            }
            var L = 72.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var l1 = 18.8;//螺纹长度
            try
            {
                l1 = Convert.ToDouble(data["thl"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l1] not found");
            }
            var l2 = 37.0;//可用长度
            try
            {
                l2 = Convert.ToDouble(data["lu"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l2] not found");
            }
            var l3 = L - l2;//柄部长度
            var d1 = 6.3;//柄部直径
            try
            {
                d1 = Convert.ToDouble(data["dmm"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var k = 5.0;//驱动器尺寸代码
            try
            {
                k = Convert.ToDouble(data["drvsc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[k] not found");
            }

            */
            
            var d = 3.0;
            var tp = 0.5;
            var L = 48.0;
            var l1 = 7.5;
            var l2 = 19.0;
            var l3 = L - l2;
            var d1 = 3.15;
            var k = 2.5;
            



            //作图

            //柄部

            var v1 = new Vector2(0, 0);
            var v0 = fun.Polar(v1, pi, L);
            var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
            var v3 = fun.Polar(v2, pi, 0.8 / 3.31 * d1 / 2);
            var v8 = fun.Polar(v2, -90 * pi / 180, 1.48 / 3.31 * d1 / 2);
            var v9 = fun.Polar(v8, pi, 8.38 / 43.52 * l3);
            var v6 = fun.Polar(v2, pi, fun.CalDistance(v8, v9));
            var v5 = fun.Polar(v6, 0, fun.CalDistance(v3, v2));
            var v4 = fun.mirrorpoint(v3, v8, v9);
            var v7 = fun.mirrorpoint(v5, v8, v9);
            var v10 = fun.Polar(v2, pi, l3);
            var v3p = fun.mirrorpoint(v3, v0, v1);
            var v4p = fun.mirrorpoint(v4, v0, v1);
            var v5p = fun.mirrorpoint(v5, v0, v1);
            var v6p = fun.mirrorpoint(v6, v0, v1);
            var v7p = fun.mirrorpoint(v7, v0, v1);
            var v8p = fun.mirrorpoint(v8, v0, v1);
            var v9p = fun.mirrorpoint(v9, v0, v1);
            var v10p = fun.mirrorpoint(v10, v0, v1);



            var arc1 = fun.DrawArc3(v4, v8, v3);
            var arc2 = fun.DrawArc3(v5, v9, v7);
            var arc3 = fun.DrawArc3(v3p, v8p, v4p);
            var arc4 = fun.DrawArc3(v7p, v9p, v5p);
            var line1 = new Line(v8, v8p);
            var polyline1 = Pus.AddPointsToLwPolyLine(v7, v4, v4p, v7p, v7);
            var polyline2 = Pus.AddPointsToLwPolyLine(v3, v5, v6);
            var polyline3 = Pus.AddPointsToLwPolyLine(v3p, v5p, v6p);
            var polyline4 = Pus.AddPointsToLwPolyLine(v6, v6p, v10p, v10, v6);

            //dxf.AddEntity(new EntityObject[] { arc1, arc2, arc3, arc4, line1, polyline1, polyline2, polyline3, polyline4 });


            fun.drawBArc(dxf, arc1, 0.2, contour);
            fun.drawBArc(dxf, arc2, 0.2, contour);
            fun.drawBArc(dxf, arc3, 0.2, contour);
            fun.drawBArc(dxf, arc4, 0.2, contour);
            fun.drawBline(dxf, line1, 0.2, contour); 
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            fun.PolyFill(dxf, polyline2, 0.2, contour);
            fun.PolyFill(dxf, polyline3, 0.2, contour);
            fun.PolyFill(dxf, polyline4, 0.2, contour);

            //颈部
            var v11 = fun.Polar(v10, -90 * pi / 180, 0.27 / 3.31 * d1 / 2);
            var v12 = fun.Polar(v11, pi, l2 - l1);
            var v13= fun.Polar(v12, -90 * pi / 180, 0.41 / 3.31 * d1 / 2);
            var v14 = fun.Polar(v13, 0, 7.6 / 15.96 * (l2 - l1));
            var v15 = new Vector2(v14.X + 3.31 / 15.96 * (l2 - l1), v14.Y - 0.51 / 3.31 * d1 / 2);
            var v16 = new Vector2(v15.X + 0.16 / 15.96 * (l2 - l1), v15.Y - 1.2 / 3.31 * d1 / 2);
            var v17 = new Vector2(v14.X + 0.64 / 15.96 * (l2 - l1), v1.Y);
            var v18 = new Vector2(v12.X, v1.Y);
            var v19 = fun.Polar(v18, -90 * pi / 180, 1.85 / 3.31 * d1 / 2);
            var v20 = fun.Polar(v19, 0, 8.18 / 15.96 * (l2 - l1));
            var v21 = new Vector2(v20.X + 3.08 / 15.96 * (l2 - l1), v20.Y - 0.53 / 3.31 * d1 / 2);
            var v12p = fun.mirrorpoint(v12, v0, v1);
            var v11p = fun.mirrorpoint(v11, v0, v1);
            var v22 = fun.Polar(v12p, 0, 11.3 / 15.96 * (l2 - l1));

            var line2 = new Line(v12, v11);
            var line3 = new Line(v12p, v11p);
            var polyline5 = Pus.AddPointsToLwPolyLine(v13, v14, v15, v16, v17, v18);
            polyline5.Vertexes[1].Bulge = -Math.Tan(11 * pi / 180 / 4);
            polyline5.Vertexes[2].Bulge = -Math.Tan(135 * pi / 180 / 4);
            polyline5.Vertexes[3].Bulge = -Math.Tan(30 * pi / 180 / 4);
            var polyline6 = Pus.AddPointsToLwPolyLine( v20, v21, v22);
            polyline6.Vertexes[0].Bulge = -Math.Tan(15 * pi / 180 / 4);
            polyline6.Vertexes[1].Bulge = -Math.Tan(140 * pi / 180 / 4);


            //dxf.AddEntity(new EntityObject[] { line2, polyline5, polyline6 });

            fun.drawBline(dxf, line2, 0.2, contour);
            fun.PolyFill(dxf, polyline5, 0.2, contour);
            fun.PolyFill(dxf, polyline6, 0.2, contour);

            //切削部分
            var v23 = new Vector2(v12.X, v1.Y + d / 2);
            var v24 = fun.Polar(v23, pi, l1);
            var v25 = fun.mirrorpoint(v24, v1, v0);
            var v26 = fun.mirrorpoint(v23, v1, v0);
            var v27 = new Vector2(v12.X - 0.75 / 15.64 * l1, v1.Y + 3.76 / 4 * d / 2);
            var v27p = new Vector2(v12.X - 1.14 / 15.64 * l1, v1.Y + 3.28 / 4 * d / 2);
            var v28 = fun.Polar(v23, pi, 1.58 / 15.64 * l1);
            var v29 = fun.Polar(v27p, pi, 1.0352 / 15.64 * l1);
            var v30 = fun.Polar(v28, pi, 1.0352 / 15.64 * l1);
            var v31 = fun.Polar(v29, pi, 1.0352 / 15.64 * l1);
            var v32 = fun.Polar(v30, pi, 1.0352 / 15.64 * l1);
            var v33 = fun.Polar(v31, pi, 1.0352 / 15.64 * l1);
            var v34 = fun.Polar(v32, pi, 1.0352 / 15.64 * l1);
            var v35 = fun.Polar(v33, pi, 1.0352 / 15.64 * l1);
            var v36 = fun.Polar(v34, pi, 1.0352 / 15.64 * l1);
            var v37 = fun.Polar(v35, pi, 1.0352 / 15.64 * l1);
            var v38 = fun.Polar(v36, pi, 1.0352 / 15.64 * l1);
            var v39 = fun.Polar(v37, pi, 1.0352 / 15.64 * l1);
            var v40 = fun.Polar(v38, pi, 1.0352 / 15.64 * l1);
            var v41 = fun.Polar(v39, pi, 1.0352 / 15.64 * l1);
            var v42 = fun.Polar(v40, pi, 1.0352 / 15.64 * l1);
            var v43 = fun.Polar(v41, pi, 1.0352 / 15.64 * l1);
            var v44 = fun.Polar(v42, pi, 1.0352 / 15.64 * l1);
            var v45 = fun.Polar(v43, pi, 1.0352 / 15.64 * l1);
            var v46 = fun.Polar(v44, pi, 1.0352 / 15.64 * l1);
            var v47 = fun.Polar(v45, pi, 1.0352 / 15.64 * l1);
            var v48 = fun.Polar(v46, pi, 1.0352 / 15.64 * l1);
            var v49 = fun.Polar(v47, pi, 1.0352 / 15.64 * l1);
            var v50 = fun.Polar(v48, pi, 1.0352 / 15.64 * l1);
            var v51 = fun.Polar(v49, pi, 1.0352 / 15.64 * l1);
            var v52 = fun.Polar(v50, pi, 1.0352 / 15.64 * l1);
            var v53 = fun.Polar(v51, pi, 1.0352 / 15.64 * l1);
            var v54 = fun.Polar(v52, pi, 1.0352 / 15.64 * l1);
            var v55 = fun.Polar(v53, pi, 1.0352 / 15.64 * l1);
            var v56 = fun.Polar(v24, -90 * pi / 180, 0.81 / 8.9 * d);
            var v57 = fun.Inters(v13, fun.Polar(v13, fun.CalAngle(v12, v27) + 8 * pi / 180, 1), v27, fun.Polar(v27, 275 * pi / 180, 1));
            var v58 = fun.Polar(v27p, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v59 = fun.Polar(v28, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v60 = fun.Polar(v29, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v61 = fun.Polar(v30, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v62 = fun.Polar(v31, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v63 = fun.Polar(v32, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v64 = fun.Polar(v33, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v65 = fun.Polar(v34, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v66 = fun.Polar(v35, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v67 = fun.Polar(v36, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v68 = fun.Polar(v37, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v69 = fun.Polar(v38, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v70 = fun.Polar(v39, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v71 = fun.Polar(v40, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v72 = fun.Polar(v41, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v73 = fun.Polar(v42, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v74 = fun.Polar(v43, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v75 = fun.Polar(v44, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v76 = fun.Polar(v45, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v77 = fun.Polar(v46, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v78 = fun.Polar(v47, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v79 = fun.Polar(v48, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v80 = fun.Polar(v49, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v81 = fun.Polar(v50, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v82 = fun.Polar(v51, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v83 = fun.Polar(v52, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v84 = fun.Polar(v53, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v85 = fun.Polar(v54, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v86 = fun.Polar(v55, fun.CalAngle(v27, v57), fun.CalDistance(v27, v57));
            var v87 = fun.Polar(v24, -90 * pi / 180, 1.65 / 8.9 * d);
            var c1 = fun.Inters(v50, v55, v51, v52);
            var c2 = fun.Inters(v50, v55, v53, v52);
            var c3 = fun.Inters(v50, v55, v53, v54);
            var c4 = fun.Inters(v81, v86, v82, v83);
            var c5 = fun.Inters(v81, v86, v83, v84);
            var c6 = fun.Inters(v81, v86, v84, v85);
            var v88 = fun.Inters(v27p, v58, v25, v26);
            var v89 = fun.Polar(v88, fun.CalAngle(v58, v59), fun.CalDistance(v58, v59));
            var v90 = fun.Inters(v29, v60, v25, v26);
            var v91 = fun.Polar(v90, fun.CalAngle(v58, v59), fun.CalDistance(v58, v59));
            var v88p = fun.Inters(v88, fun.Polar(v88, fun.CalAngle(v90, v89), 1), v12p, fun.Polar(v12p, pi, 1));
            var v92 = fun.Polar(v90, pi, fun.CalDistance(v88, v90));
            var v93 = fun.Polar(v91, pi, fun.CalDistance(v89, v91));
            var v94 = fun.Polar(v92, pi, fun.CalDistance(v89, v91));
            var v95 = fun.Polar(v93, pi, fun.CalDistance(v89, v91));
            var v96 = fun.Polar(v94, pi, fun.CalDistance(v89, v91));
            var v97 = fun.Polar(v95, pi, fun.CalDistance(v89, v91));
            var v98 = fun.Polar(v96, pi, fun.CalDistance(v89, v91));
            var v99 = fun.Polar(v97, pi, fun.CalDistance(v89, v91));
            var v100 = fun.Polar(v98, pi, fun.CalDistance(v89, v91));
            var v101 = fun.Polar(v99, pi, fun.CalDistance(v89, v91));
            var v102 = fun.Polar(v100, pi, fun.CalDistance(v89, v91));
            var v103 = fun.Polar(v101, pi, fun.CalDistance(v89, v91));
            var v104 = fun.Polar(v102, pi, fun.CalDistance(v89, v91));
            var v105 = fun.Polar(v103, pi, fun.CalDistance(v89, v91));
            var v106 = fun.Polar(v104, pi, fun.CalDistance(v89, v91));
            var v107 = fun.Polar(v105, pi, fun.CalDistance(v89, v91));
            var v108 = fun.Polar(v106, pi, fun.CalDistance(v89, v91));
            var v109 = fun.Polar(v107, pi, fun.CalDistance(v89, v91));
            var v110 = fun.Polar(v108, pi, fun.CalDistance(v89, v91));
            var v111 = fun.Polar(v109, pi, fun.CalDistance(v89, v91));
            var v112 = fun.Polar(v110, pi, fun.CalDistance(v89, v91));
            var v113 = fun.Polar(v111, pi, fun.CalDistance(v89, v91));
            var v114 = fun.Polar(v112, pi, fun.CalDistance(v89, v91));
            var v115 = fun.Polar(v113, pi, fun.CalDistance(v89, v91));
            var v116 = fun.Polar(v114, pi, fun.CalDistance(v89, v91));
            var v117 = fun.Polar(v25, 90 * pi / 180, 0.84 / 8.9 * d);
            var c7 = fun.Inters(v113, v114, v112, v117);
            var c8 = fun.Inters(v115, v114, v112, v117);
            var c9 = fun.Inters(v115, v116, v112, v117);
            var v118 = fun.Polar(v1, pi, L);
            var v119 = fun.Polar(v118, -90 * pi / 180, 2.04 / 8 * d);
            var v121p = fun.Polar(v118, -90 * pi / 180, 2.78 / 8 * d);
            var v121 = fun.Inters(v58, v88, v121p, fun.Polar(v121p, 0, 1));
            var v120p = fun.Polar(v121, fun.CalAngle(v90, v89), fun.CalDistance(v90, v89));
            var v120 = fun.Inters(v121, v120p, v19, fun.Polar(v19, pi, 1));
            var v122 = fun.Polar(v121, fun.CalAngle(v88, v89), fun.CalDistance(v88, v89));
            var v123 = fun.Polar(v121, pi, fun.CalDistance(v88, v90));
            var v124 = fun.Polar(v122, pi, fun.CalDistance(v88, v90));
            var v125 = fun.Polar(v123, pi, fun.CalDistance(v88, v90));
            var v126 = fun.Polar(v124, pi, fun.CalDistance(v88, v90));
            var v127 = fun.Polar(v125, pi, fun.CalDistance(v88, v90));
            var v128 = fun.Polar(v126, pi, fun.CalDistance(v88, v90));
            var v129 = fun.Polar(v127, pi, fun.CalDistance(v88, v90));
            var v130 = fun.Polar(v128, pi, fun.CalDistance(v88, v90));
            var v131 = fun.Polar(v129, pi, fun.CalDistance(v88, v90));
            var v132 = fun.Polar(v130, pi, fun.CalDistance(v88, v90));
            var v133 = fun.Polar(v131, pi, fun.CalDistance(v88, v90));
            var v134 = fun.Polar(v132, pi, fun.CalDistance(v88, v90));
            var v135 = fun.Polar(v133, pi, fun.CalDistance(v88, v90));
            var v136 = fun.Polar(v134, pi, fun.CalDistance(v88, v90));
            var v137 = fun.Polar(v135, pi, fun.CalDistance(v88, v90));
            var v138 = fun.Polar(v136, pi, fun.CalDistance(v88, v90));
            var v139 = fun.Polar(v137, pi, fun.CalDistance(v88, v90));
            var v140 = fun.Polar(v138, pi, fun.CalDistance(v88, v90));
            var v141 = fun.Polar(v139, pi, fun.CalDistance(v88, v90));
            var v142 = fun.Polar(v140, pi, fun.CalDistance(v88, v90));
            var v143 = fun.Polar(v141, pi, fun.CalDistance(v88, v90));
            var v144 = fun.Polar(v142, pi, fun.CalDistance(v88, v90));
            var v145 = fun.Polar(v143, pi, fun.CalDistance(v88, v90));
            var v1450 = fun.Polar(v144, pi, fun.CalDistance(v88, v90));
            var v1451 = fun.Polar(v145, pi, fun.CalDistance(v88, v90));
            var v1452 = fun.Polar(v1450, pi, fun.CalDistance(v88, v90));
            var v1453 = fun.Polar(v1451, pi, fun.CalDistance(v88, v90));
            var c10 = fun.Inters(v145, v119, v1450, v1451);
            var c11 = fun.Inters(v145, v119, v1452, v1451);
            var c12 = fun.Inters(v145, v119, v1453, v1452);
            var v147 = fun.Inters(v121, v88, v1, v118);
            var v146 = fun.Inters(v120, fun.Polar(v120, fun.CalAngle(v121, v147), 1), v1, v118);
            var v148 = fun.Inters(v121, fun.Polar(v121, fun.CalAngle(v121, v147), 1), v1, v118);
            var v149 = fun.Inters(v122, fun.Polar(v122, fun.CalAngle(v121, v147), 1), v1, v118);
            var v150 = fun.Inters(v123, fun.Polar(v123, fun.CalAngle(v121, v147), 1), v1, v118);
            var v151 = fun.Inters(v124, fun.Polar(v124, fun.CalAngle(v121, v147), 1), v1, v118);
            var v152 = fun.Inters(v125, fun.Polar(v125, fun.CalAngle(v121, v147), 1), v1, v118);
            var v153 = fun.Inters(v126, fun.Polar(v126, fun.CalAngle(v121, v147), 1), v1, v118);
            var v154 = fun.Inters(v127, fun.Polar(v127, fun.CalAngle(v121, v147), 1), v1, v118);
            var v155 = fun.Inters(v128, fun.Polar(v128, fun.CalAngle(v121, v147), 1), v1, v118);
            var v156 = fun.Inters(v129, fun.Polar(v129, fun.CalAngle(v121, v147), 1), v1, v118);
            var v157 = fun.Inters(v130, fun.Polar(v130, fun.CalAngle(v121, v147), 1), v1, v118);
            var v158 = fun.Inters(v131, fun.Polar(v131, fun.CalAngle(v121, v147), 1), v1, v118);
            var v159 = fun.Inters(v132, fun.Polar(v132, fun.CalAngle(v121, v147), 1), v1, v118);
            var v160 = fun.Inters(v133, fun.Polar(v133, fun.CalAngle(v121, v147), 1), v1, v118);
            var v161 = fun.Inters(v134, fun.Polar(v134, fun.CalAngle(v121, v147), 1), v1, v118);
            var v162 = fun.Inters(v135, fun.Polar(v135, fun.CalAngle(v121, v147), 1), v1, v118);
            var v163 = fun.Inters(v136, fun.Polar(v136, fun.CalAngle(v121, v147), 1), v1, v118);
            var v164 = fun.Inters(v137, fun.Polar(v137, fun.CalAngle(v121, v147), 1), v1, v118);
            var v165 = fun.Inters(v138, fun.Polar(v138, fun.CalAngle(v121, v147), 1), v1, v118);
            var v166 = fun.Inters(v139, fun.Polar(v139, fun.CalAngle(v121, v147), 1), v1, v118);
            var v167 = fun.Inters(v140, fun.Polar(v140, fun.CalAngle(v121, v147), 1), v1, v118);
            var v168 = fun.Inters(v141, fun.Polar(v141, fun.CalAngle(v121, v147), 1), v1, v118);
            var v169 = fun.Inters(v142, fun.Polar(v142, fun.CalAngle(v121, v147), 1), v1, v118);
            var v170 = fun.Inters(v143, fun.Polar(v143, fun.CalAngle(v121, v147), 1), v1, v118);
            var v171 = fun.Inters(v144, fun.Polar(v144, fun.CalAngle(v121, v147), 1), v1, v118);
            var v172 = fun.Inters(v145, fun.Polar(v145, fun.CalAngle(v121, v147), 1), v1, v118);
            var v173 = fun.Inters(v1450, fun.Polar(v1450, fun.CalAngle(v121, v147), 1), v1, v118);
            var v174 = fun.Inters(v1452, fun.Polar(v1452, fun.CalAngle(v121, v147), 1), v1, v118);
            var v175 = fun.Inters(c10, fun.Polar(c10, fun.CalAngle(v121, v147), 1), v1, v118);
            var v176 = fun.Inters(c11, fun.Polar(c11, fun.CalAngle(v121, v147), 1), v1, v118);
            var v177 = fun.Inters(c12, fun.Polar(c12, fun.CalAngle(v121, v147), 1), v1, v118);





            var polyline7 = Pus.AddPointsToLwPolyLine(v12, v27, v27p, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, c1, c2, v53, c3, v55, v56);
            var polyline8 = Pus.AddPointsToLwPolyLine(v13, v57, v58, v59, v60, v61, v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76, v77, v78, v79, v80, v81, v82, c4, c5, v84, c6, v86, v87);
            var polyline9 = Pus.AddPointsToLwPolyLine(v11p, v88p, v88, v89, v90, v91, v92, v93, v94, v95, v96, v97, v98, v99, v100, v101, v102, v103, v104, v105, v106, v107, v108, v109, v110, v111, v112, v113, c7, c8, v115, c9, v117, v56);
            var polyline10 = Pus.AddPointsToLwPolyLine(v20, v120, v121, v122, v123, v124, v125, v126, v127, v128, v129, v130, v131, v132, v133, v134, v135, v136, v137, v138, v139, v140, v141, v142, v143, v144, v145, v1450, c10, c11, v1452, c12, v119);

            var line4 = new Line(v27, v57);
            var line5 = new Line(v28, v59);
            var line6 = new Line(v29, v60);
            var line7 = new Line(v30, v61);
            var line8 = new Line(v31, v62);
            var line9 = new Line(v32, v63);
            var line10 = new Line(v33, v64);
            var line11 = new Line(v34, v65);
            var line12 = new Line(v35, v66);
            var line13 = new Line(v36, v67);
            var line14 = new Line(v37, v68);
            var line15 = new Line(v38, v69);
            var line16 = new Line(v39, v70);
            var line17 = new Line(v40, v71);
            var line18 = new Line(v41, v72);
            var line19 = new Line(v42, v73);
            var line20 = new Line(v43, v74);
            var line21 = new Line(v44, v75);
            var line22 = new Line(v45, v76);
            var line23 = new Line(v46, v77);
            var line24 = new Line(v47, v78);
            var line25 = new Line(v48, v79);
            var line26 = new Line(v49, v80);
            var line27 = new Line(v50, v81);
            var line28 = new Line(v51, v82);
            var line29 = new Line(v27p, v58);
            var line30 = new Line(c1, c4);
            var line31 = new Line(c2, c5);
            var line32 = new Line(c3, c6);
            var line33 = new Line(v53, v84);
            var line34 = new Line(v55, v86);

            var line35 = new Line(v120, v146);
            var line36 = new Line(v121, v148);
            var line36_ = new Line(v122, v149);
            var line37 = new Line(v123, v150);
            var line38 = new Line(v124, v151);
            var line39 = new Line(v125, v152);
            var line40 = new Line(v126, v153);
            var line41 = new Line(v127, v154);
            var line42 = new Line(v128, v155);
            var line43 = new Line(v129, v156);
            var line44 = new Line(v130, v157);
            var line45 = new Line(v131, v158);
            var line46 = new Line(v132, v159);
            var line47 = new Line(v133, v160);
            var line48 = new Line(v134, v161);
            var line49 = new Line(v135, v162);
            var line50 = new Line(v136, v163);
            var line51 = new Line(v137, v164);
            var line52 = new Line(v138, v165);
            var line53 = new Line(v139, v166);
            var line54 = new Line(v140, v167);
            var line55 = new Line(v141, v168);
            var line56 = new Line(v142, v169);
            var line57 = new Line(v143, v170);
            var line58 = new Line(v144, v171);
            var line59 = new Line(v145, v172);
            var line60 = new Line(v1450, v173);
            var line61 = new Line(v1452, v174);
            var line62 = new Line(c10, v175);


            var line63 = new Line(c11, v176);
            var line64 = new Line(c12, v177);
            var line65 = new Line(v18, v118);



            //dxf.AddEntity(new EntityObject[] { polyline7, polyline8, polyline9, polyline10 ,line4, line5, line6, line7, line8, line9, line10, line11, line12, line13, line14, line15, line16, line17, line18, line19, line20, line21, line22, line23, line24, line25, line26, line27, line28, line29, line30, line31, line32, line33, line34 });


            //dxf.AddEntity(new EntityObject[] { line35, line36, line36_, line37, line38, line39, line40, line41, line42, line43, line44, line45, line46, line47, line48, line49, line50, line51, line52, line53, line54, line55, line56, line57, line58, line59, line60, line61, line62, line63, line64, line65 });


            fun.drawBline(dxf, line4, 0.2, contour);
            fun.drawBline(dxf, line5, 0.2, contour);
            fun.drawBline(dxf, line6, 0.2, contour);
            fun.drawBline(dxf, line7, 0.2, contour);
            fun.drawBline(dxf, line8, 0.2, contour);
            fun.drawBline(dxf, line9, 0.2, contour);
            fun.drawBline(dxf, line10, 0.2, contour);
            fun.drawBline(dxf, line11, 0.2, contour);
            fun.drawBline(dxf, line12, 0.2, contour);
            fun.drawBline(dxf, line13, 0.2, contour);
            fun.drawBline(dxf, line14, 0.2, contour);
            fun.drawBline(dxf, line15, 0.2, contour);
            fun.drawBline(dxf, line16, 0.2, contour);
            fun.drawBline(dxf, line17, 0.2, contour);
            fun.drawBline(dxf, line18, 0.2, contour);
            fun.drawBline(dxf, line19, 0.2, contour);
            fun.drawBline(dxf, line20, 0.2, contour);
            fun.drawBline(dxf, line21, 0.2, contour);
            fun.drawBline(dxf, line22, 0.2, contour);
            fun.drawBline(dxf, line23, 0.2, contour);
            fun.drawBline(dxf, line24, 0.2, contour);
            fun.drawBline(dxf, line25, 0.2, contour);
            fun.drawBline(dxf, line26, 0.2, contour);
            fun.drawBline(dxf, line27, 0.2, contour);
            fun.drawBline(dxf, line28, 0.2, contour);
            fun.drawBline(dxf, line29, 0.2, contour);
            fun.drawBline(dxf, line30, 0.2, contour);
            fun.drawBline(dxf, line31, 0.2, contour);
            fun.drawBline(dxf, line32, 0.2, contour);
            fun.drawBline(dxf, line33, 0.2, contour);
            fun.drawBline(dxf, line34, 0.2, contour);
            fun.drawBline(dxf, line35, 0.2, contour);
            fun.drawBline(dxf, line36, 0.2, contour);
            fun.drawBline(dxf, line36_, 0.2, contour);
            fun.drawBline(dxf, line37, 0.2, contour);
            fun.drawBline(dxf, line38, 0.2, contour);
            fun.drawBline(dxf, line39, 0.2, contour);
            fun.drawBline(dxf, line40, 0.2, contour);
            fun.drawBline(dxf, line41, 0.2, contour);
            fun.drawBline(dxf, line42, 0.2, contour);
            fun.drawBline(dxf, line43, 0.2, contour);
            fun.drawBline(dxf, line44, 0.2, contour);
            fun.drawBline(dxf, line45, 0.2, contour);
            fun.drawBline(dxf, line46, 0.2, contour);
            fun.drawBline(dxf, line47, 0.2, contour);
            fun.drawBline(dxf, line48, 0.2, contour);
            fun.drawBline(dxf, line49, 0.2, contour);
            fun.drawBline(dxf, line50, 0.2, contour);
            fun.drawBline(dxf, line51, 0.2, contour);
            fun.drawBline(dxf, line52, 0.2, contour);
            fun.drawBline(dxf, line53, 0.2, contour);
            fun.drawBline(dxf, line54, 0.2, contour);
            fun.drawBline(dxf, line55, 0.2, contour);
            fun.drawBline(dxf, line56, 0.2, contour);
            fun.drawBline(dxf, line57, 0.2, contour);
            fun.drawBline(dxf, line58, 0.2, contour);
            fun.drawBline(dxf, line59, 0.2, contour);
            fun.drawBline(dxf, line60, 0.2, contour);
            fun.drawBline(dxf, line61, 0.2, contour);
            fun.drawBline(dxf, line62, 0.2, contour);
            fun.drawBline(dxf, line63, 0.2, contour);
            fun.drawBline(dxf, line64, 0.2, contour);
            fun.drawBline(dxf, line65, 0.2, contour);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            fun.PolyFill(dxf, polyline10, 0.2, contour);

            //基准线

            var a1 = fun.Polar(v1, 0, 10);
            var a2 = fun.Polar(v1, pi, L + 10);
            var a3 = fun.Polar(a1, 0, 50);
            var a4 = fun.Polar(a3, pi, 1.5 * k);
            var a5 = fun.Polar(a3, 0, 1.5 * k);
            var a6 = fun.Polar(a3, 90 * pi / 180, 1.5 * k);
            var a7 = fun.Polar(a3, -90 * pi / 180, 1.5 * k);

            var a8 = fun.Polar(a3, 90 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a9 = fun.Polar(a3, 0 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a10 = fun.Polar(a3, -90 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a11 = fun.Polar(a3, 180 * pi / 180, k / 2 / Math.Cos(45 * pi / 180));
            var a12 = fun.Inters(v2, v3, a8, a9);
            var a13 = fun.Polar(a9, fun.CalAngle(a9, a8), fun.CalDistance(a8, a12));
            var a14 = fun.Polar(a9, fun.CalAngle(a9, a10), fun.CalDistance(a8, a12));
            var a15 = fun.Polar(a10, fun.CalAngle(a10, a9), fun.CalDistance(a8, a12));
            var a16 = fun.Polar(a10, fun.CalAngle(a10, a11), fun.CalDistance(a8, a12));
            var a17 = fun.Polar(a11, fun.CalAngle(a11, a10), fun.CalDistance(a8, a12));
            var a18 = fun.Polar(a11, fun.CalAngle(a11, a8), fun.CalDistance(a8, a12));
            var a19 = fun.Polar(a8, fun.CalAngle(a8, a11), fun.CalDistance(a8, a12));

            var line66 = new Line(a1, a2);
            line66.Layer = centre;
            line66.Lineweight = Lineweight.W25;
            line66.Linetype = Linetype.DashDot;
            var line67 = new Line(a4, a5);
            line67.Layer = centre;
            line67.Lineweight = Lineweight.W25;
            line67.Linetype = Linetype.DashDot;
            var line68 = new Line(a6, a7);
            line68.Layer = centre;
            line68.Lineweight = Lineweight.W25;
            line68.Linetype = Linetype.DashDot;

            var polyline11 = Pus.AddPointsToLwPolyLine(a12, a13, a14, a15, a16, a17, a18, a19, a12);

            //dxf.AddEntity(new EntityObject[] { line66, line67, line68, polyline11 });

            fun.PolyFill(dxf, polyline11, 0.2, contour);
            dxf.AddEntity(new EntityObject[] { line66, line67, line68 });

            var hatchpoly1 = polyline11;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


            //标注

            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度


            fun.dimrot1(dxf, v3p, v3, -90, offset, 0, height, arrowsize, exline, "DMM=" + d1, "", "");
            fun.dimrot1(dxf, v117, v88p, 180, offset, 0, height, arrowsize, exline, "l1=" + l1, "", "");
            fun.dimrot1(dxf, v117, v10p, 180, offset * 2, 0, height, arrowsize, exline, "l2=" + l2, "", "");
            fun.dimrot1(dxf, v117, v8p, 180, offset * 3, 0, height, arrowsize, exline, "OAL=" + l2, "", "");
            fun.dimrot1(dxf, a13, a16, -135, offset , 0, height, arrowsize, exline, "k=" + k, "", "");






            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }


    }
}
